<template>
  <el-dialog
      title="开门记录"
      :visible="visible"
      width="1000px"
      :destroy-on-close="true"
      :lock-scroll="false"
      @update:visible="updateVisible">
    <ele-pro-table
        ref="table"
        :datasource="url"
        :columns="columns"
        max-height="calc(100vh - 385px)">
    </ele-pro-table>
  </el-dialog>
</template>

<script>

export default {
  props: {
    visible: Boolean,
    data: Object
  },
  computed: {
    url() {
      return '/open_log/index?equip=' + this.data.id
    }
  },
  data() {
    return {
      columns: [
        {
          prop: 'id',
          label: 'ID',
          width: 60,
          align: 'center',
          showOverflowTooltip: true,
          fixed: "left"
        },
        {
          prop: 'ctype',
          label: '开门角色 ',
          showOverflowTooltip: true,
          width: 100,
          align: 'center',
          formatter: (row, column, cellValue) => {
            return cellValue === 2 ? '教师' : '学生';
          }
        },
        {
          prop: 'name',
          label: '开门人员',
          showOverflowTooltip: true,
          minWidth: 100,
          align: 'center',
        },

        {
          prop: 'code',
          label: '学号/手机号',
          showOverflowTooltip: true,
          minWidth: 150,
          align: 'center',
        },
        {
          prop: 'create_time',
          label: '开门时间',
          showOverflowTooltip: true,
          minWidth: 160,
          align: 'center',
          formatter: (row, column, cellValue) => {
            return this.$util.toDateString(cellValue)
          }
        }
      ]
    }
  },
  methods: {
    updateVisible(value) {
      this.$emit('update:visible', value)
    },

  }
}
</script>

